<?php

$battleid = $_POST["battleid"];

$dbname = "tactickstest";
$connection = mysql_connect("tidesinreturn.gardenofmadness.org", "tacticksadmin",
                            "123abc") or die("Error connecting to SQL.");

$db = mysql_select_db($dbname, $connection);

$query = "select currenttick from BATTLES where id = '" . 
          mysql_real_escape_string($battleid) . "'";

$result = mysql_query($query, $connection) or die("Could not complete database query: " . mysql_error());
$num = mysql_num_rows($result);

echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
if ($num != 0)
{
    $row = mysql_fetch_array($result);
    echo "<currenttick>" . $row["currenttick"] . "</currenttick>";
}
else
{
    echo "<currenttick>-1</currenttick>";
}

?>
